package com.ht.safe.entity;

import org.hibernate.annotations.Index;

import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: 薄成文 13-7-19 上午10:31
 * To change this template use File | Settings | File Templates.
 */
public class Card {
    /**
     * 卡号
     */
    @Column(name = "card_id", nullable = false, unique = true)
    @Index(name="idx_card_cardid")
    private String cardId;

    /**
     * 卡类型:巡更卡，访客卡，员工卡
     */
    private String type;

    /**
     * 等级
     */
    private Integer authority;

    /**
     * 标注卡的附加属性，Lost, Stolen, Destroyed
     */
    @Enumerated(EnumType.STRING)
    private CommentType comment;

    public static enum CommentType {
        /** 丢失 */LOST, /** 被盗 */STOLEN, /** 损坏 */DESTROYED;
        public String getLabel() {
            switch (this) {
                case LOST:
                    return "丢失";
                case STOLEN:
                    return "被盗";
                case DESTROYED:
                    return "损坏";
            }
            return null;
        }
    }
}
